#include <algorithm>
#include <cstdio>
#include <cstring>
const int N = 2005, mod = 1e9 + 7;
int n, m;
bool map[N][N];
int f[2][N][N];
inline long long qpow(long long base, int index) {
  long long res = 1;
  while (index) {
    if (index & 1) (res *= base) %= mod;
    (base *= base) %= mod, index >>= 1;
  }
  return res;
}
int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("maze.in", "r", stdin);
  freopen("maze.out", "w", stdout);
#endif
#endif

  scanf("%d%d", &n, &m);
  char tmp[N];
  for (register int i = 1; i <= n; ++i) {
    scanf("%s", &tmp[1]);
    register int len = strlen(tmp + 1);
    for (register int j = 1; j <= len; ++j) {
      map[i][j] = tmp[j] - '0';
    }
  }
  f[0][1][1] = 1;
  for (register int i = 2; i <= n + m - 1; ++i) {
    memset(f[!(i & 1)], 0, sizeof(f[!(i & 1)]));
    for (register int j = std::max(1, i - n + 1); j <= std::min(m, i); ++j) {
      if (map[i - j + 1][j]) continue;
      for (register int k = std::max(1, i - n + 1); k <= std::min(m, i); ++k) {
        if ((map[i - k + 1][k] || k == j) && i != n + m - 1) continue;
        f[!(i & 1)][j][k] =
            ((((f[i & 1][j - 1][k - 1] + f[i & 1][j][k]) % mod) + f[i & 1][j][k - 1]) %
                 mod +
             f[i & 1][j - 1][k]) %
            mod;
        f[!(i & 1)][j][k] %= mod;
      }
    }
  }
  printf("%lld", (f[!((n + m - 1) & 1)][m][m] * qpow(2, mod - 2)) % mod);
  return 0;
}